package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class TestContorller {
    @RequestMapping("/")
    public String toIndex(HttpSession session){
        if(!session.isNew()){
            return "success";
        }
        return "index";
    }
    @RequestMapping("/success")
    public String toSucccess(String username,String password,HttpSession session){
        if(username.equals("admin")&&password.equals("123456")){
            session.setAttribute(username,password);
            return "success";
        }
        return "index";
    }
    @RequestMapping("/logout")
    public String toLogout(HttpSession session){
        session.invalidate();
        return "index";
    }
}
